#ifndef CUBE_CPP
#define CUBE_CPP

#include "cube.h"

void squareSurface(double x)
{
	glVertex3d(-x,-x,0);
	glVertex3d(x,-x,0);
	glVertex3d(x,x,0);
	glVertex3d(-x,x,0);
}

void cube::draw()
{
	glPushMatrix();
		glLoadIdentity();
		glTranslated(_pos->x,_pos->y,_pos->z);
		glBegin(GL_QUADS);
			//front
			glPushMatrix();
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
			
			//back
			glPushMatrix();
				glRotated(180.0,0.0,1.0,0.0);
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
			
			//right
			glPushMatrix();
				glRotated(90.0,0.0,1.0,0.0);
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
			
			//left
			glPushMatrix();
				glRotated(270.0,0.0,1.0,0.0);
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
			
			//down
			glPushMatrix();
				glRotated(270.0,1.0,0.0,0.0);
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
			
			//top
			glPushMatrix();
				glRotated(90.0,1.0,0.0,0.0);
				glTranslated(0,0,5);
				squareSurface(5);
			glPopMatrix();
		glEnd();
	glPopMatrix();
}

Vec cube::pos(Vec p)
{
	*_pos=p;
	return *_pos;
}

Vec cube::pos()
{
	return *_pos;
}
#endif
